package com.xjl.example.aqs;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

/**
 * Created by xiaojinlu1990@163.com on 2019/11/30.
 */
@Slf4j
public class FutureExample  {

    static class myCallable implements Callable<String>{

        @Override
        public String call() throws Exception {
            Thread.sleep(1000);
            log.info("do Something start");
            return "Down";
        }
    }

    public static void main(String[] args) throws InterruptedException, ExecutionException {
        ExecutorService service = Executors.newCachedThreadPool();
        Future<String> future = service.submit(new myCallable());
        Thread.sleep(1000);
            log.info("获取返回值{}",future.get().toString());



    }




}
